package com.model;

import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

public class AnggotaTabelModel extends AbstractTableModel {

    private String columnsName[] = {"Nama", "ID Anggota"};
    private ArrayList<Anggota> data;

    public AnggotaTabelModel() {
    }

    public AnggotaTabelModel(ArrayList<Anggota> data) {
        this.data = data;
    }

    @Override
    public int getRowCount() {
        return getData().size();
    }

    public String getColumnsName(int col) {
        return columnsName[col];
    }

    @Override
    public int getColumnCount() {
        return columnsName.length;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Anggota ang = getData().get(rowIndex);
        if (columnIndex == 0) {
            return ang.getNama();
        } else {
            return ang.getIdAnggota();
        }
    }

    public ArrayList<Anggota> getData() {
        return data;
    }

    public void setData(ArrayList<Anggota> data) {
        this.data = data;
    }
}
